<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %><%--
  Created by IntelliJ IDEA.
  User: 76053
  Date: 2020/3/27
  Time: 10:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册处理页面</title>
</head>
<body>
        <%
        String dbuser=    request.getParameter("user");
        String dbpassword=    request.getParameter("password");

           //1.通过反射加载驱动
            Class.forName("com.mysql.jdbc.Driver");
            //2.建立连接
            String url="jdbc:mysql://localhost:3306/wl18301";
            //mysql用户名
            String user="root";
            //mysql密码
            String password="root";

           Connection con= DriverManager.getConnection(url,user,password);

           //3.执行sql语句
            String sql="insert into student(s_user,s_password) values(?,?)";
            PreparedStatement sta= con.prepareStatement(sql);
            sta.setString(1,dbuser);
            sta.setString(2,dbpassword);
            /*update  增删改*/
            int i=sta.executeUpdate();

            //4.处理结果
            if(i>0){
              response.sendRedirect("login.jsp");
            }else{
                response.sendRedirect("insertNewUser.jsp");
            }

        %>



</body>
</html>
